<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
           <meta name="author" content="Zhang Cheng">
		<title></title>
		<style>
			.v-enter,
			.v-leave-to{
				opacity: 0;
				transform: translateX(50px);
			}
			.v-enter-active,
			.v-leave-active{
				transition: all 0.8s ease; 
			}
			/*方法1v-move和v-leave-active 两个类配合使用，实现组件切换时触发渐变的列表效果*/
			/*.v-move{
				transition: all 0.8s ease;
			}
			.v-leave-active{
				position: absolute;
			}*/
		</style>
		<script src="js/vue.js" ></script>
	</head>
	<body>
		<div id="app">
			
			<a href="" @click.prevent="comName='login'">登录</a>
			<a href="" @click.prevent="comName='reg'">注册</a>
			<!--
            组件过渡类似于元素过渡只需要用 transition将组件包起来就可以
            -->
            <!--
            	方法2，transition 的mode属性 设置组件切换时候的模式
            -->
			<transition mode="out-in">
				<component :is="comName"></component>
			</transition>
			
			
			

		</div>
		<template id="login">
		    <h2>这是login组件</h2>
		
		</template>
		<template id="reg">
		    <h2>这是reg组件</h2>
		
		</template>
		<script>
			Vue.component('login',{
				template:'#login'
			})
			Vue.component('reg',{
				template:'#reg'
			})
			
			var app = new Vue({
				el:'#app',
				data:{
					//flag:true,
					comName:'login',
				},
				methods:{
					
				}
			});
		</script>
	</body>
</html>